<%@page contentType="text/html" pageEncoding="UTF-8" 
        import="java.io.*,
        java.util.*,
        java.sql.*, 
        javax.sql.*, 
        org.brickred.socialauth.*"%>
<%

    String text = request.getParameter("wordList");
    String listName = request.getParameter("listName");
    String note = request.getParameter("note");
    //System.out.println(text);
   
    String uid = (String) session.getAttribute("uid");
    if (uid == null || text == null) {
        return;
    }
    if (listName == null) {
        listName = (new java.util.Date()).toString().replace("\\W", "_");
    }
    Connection con = com.elookinto.wordlist.Util.getCon();
    if (note != null && note.trim().length() > 0) {
        note = note.trim();
        if (note.length() >1000) note = note.substring(0,1000);
        //con.createStatement().execute();
        PreparedStatement st = con.prepareStatement("insert into note (listname, uid, txt) values(?,?,?) ");
        st.setString(1, listName);
        st.setString(2, uid);
        st.setString(3, note);
        st.executeUpdate();

    }
    if (text.length() >1000) text = text.substring(0,1000);
    String words[] = text.split("\\W+|\\d+");
    HashSet<String> hs = new HashSet(Arrays.asList(words));

    PreparedStatement st = con.prepareStatement("insert into wordlist (word, listname, uid, insert_time) values(?,?,?, current_timestamp) ");
    for (String word : hs) {
        if (word.trim().length() == 0 || word.trim().length()>35) {
            continue;
        }
        st.setString(1, word);
        st.setString(2, listName);
        st.setString(3, uid);
        try {
            st.execute();
        } catch (Exception e) {
        }
    }
    st.close();
    con.close();
    out.println("saved");

%>
